package cn.getech.data.development.enums

/**
 * hdfs的文件分隔符
 */
object DelimitFormat extends Enumeration {
  type DelimitFormat = Value
  val comma = Value(1, ",")
  val semicolon = Value(2, ";")
  val space = Value(3, " ")
  val tab = Value(4, "\t")
  val defaultDel = Value(5, "\\001")
  val syncToHive = Value(6, "&")

  def getChar(index: Int): String = {
    val format = this.withFormat(index)
    if (format == null) return null
    format.toString
  }

  def withFormat(index: Int): DelimitFormat = {
    if (!exists(index)) return null
    values.find(_.id == index).get
  }

  def exists(index: Int): Boolean = {
    values.exists(_.id == index)
  }
}

